﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Loyalty.Core.Entities
{
    public class Profile
    {
        public virtual int Id { get; set; }

        public virtual string Firstname { get; set; }

        public virtual string Lastname { get; set; }

        public virtual string FatherName { get; set; }

        public virtual string NationalCode { get; set; }

        public virtual DateTime? BirthDate { get; set; }

        public virtual bool IsMariddied { get; set; }

        public virtual string CellPhone { get; set; }

        public virtual string CodePerson { get; set; }

        public virtual string Address { get; set; }

        public virtual string PostalCode { get; set; }

        public virtual string PhoneNumber { get; set; }

        public virtual string ShortStory { get; set; }

        public virtual string FullStory { get; set; }

        public virtual DateTime MarrigeDate { get; set; }

        public virtual bool Gender { get; set; }              

        public virtual City City { get; set; }

        public virtual int? LinkCityId { get; set; }

        public virtual ICollection<Skill> Skills { get; set; }

        public virtual ICollection<ProfileJob> ProfileJobs { get; set; }

        public virtual ICollection<ProfileGrade> ProfileGrades { get; set; }

    }
}


namespace Loyalty.Core.Entities.Mapping
{
    public class ProfileMap : EntityTypeConfiguration<Profile>
    {
        public ProfileMap()
        {
            this.ToTable("Profile");
            this.HasKey(x => x.Id);

            this.Property(x => x.Firstname).HasMaxLength(150).HasColumnName("FirstName");
            this.Property(x => x.Lastname).HasMaxLength(150).HasColumnName("LastName");
            this.Property(x => x.FatherName).HasMaxLength(150).HasColumnName("FatherName");
            this.Property(x => x.NationalCode).HasMaxLength(15).HasColumnName("NationalCode");
            this.Property(x => x.BirthDate).HasColumnName("BirthDate");
            this.Property(x => x.IsMariddied).HasColumnName("IsMarride");
            this.Property(x => x.CellPhone).HasMaxLength(15).HasColumnName("CellPhone");
            this.Property(x => x.CodePerson).HasMaxLength(20).HasColumnName("CodePerson");
            this.Property(x => x.Address).HasMaxLength(500).HasColumnName("Address");
            this.Property(x => x.PostalCode).HasMaxLength(15).HasColumnName("PostalCode");
            this.Property(x => x.PhoneNumber).HasMaxLength(15).HasColumnName("PhoneNumber");
            this.Property(x => x.ShortStory).HasMaxLength(150).HasColumnName("ShortStory");
            this.Property(x => x.FullStory).HasColumnName("FullStory");
            this.Property(x => x.MarrigeDate).HasColumnName("MarrideDate");
            this.Property(x => x.Gender).HasColumnName("Gender");

            this.HasOptional(x => x.City).WithMany(x => x.Profiles).HasForeignKey(x => x.LinkCityId);
            
        }
    }
}